package model

import (
	"github.com/shopspring/decimal"
	"gorm.io/gorm"
)

type GoodsType struct { // 商品类型表
	ID             int
	Name           string            `gorm:"size:20;comment:种类名称"`
	Logo           string            `gorm:"size:20;comment:标识"`
	Image          string            `gorm:"comment:商品类型图片"`
	GoodsSKUs      []*GoodsSKU       `gorm:"foreignKey:GoodsType_Id;references:ID"`
	IndexGoodsType []*IndexGoodsType `gorm:"foreignKey:GoodsType_Id;references:ID"`
	gorm.Model
}

type GoodsSPU struct { // 商品SPU表
	ID        int
	Name      string      `gorm:"size:20;comment:商品SPU名称"`
	Detail    string      `gorm:"size:255;comment:商品详情"`
	GoodsSKUs []*GoodsSKU `gorm:"foreignKey:GoodsSPU_Id;references:ID"`
	gorm.Model
}

type GoodsSKU struct { // 商品SKU表
	ID              int
	Name            string          `gorm:"size:20;comment:商品种类"`
	Desc            string          `gorm:"size:256;comment:商品简介"`
	Price           decimal.Decimal `gorm:"type:decimal(10,2);comment:商品价格"`
	Unite           string          `gorm:"size:20;comment:商品单位"`
	Image           string          `gorm:"comment:商品图片"`
	Stock           int             `gorm:"default:0;comment:商品库存"`
	Sales           int             `gorm:"default:0;comment:商品销量"`
	Status          bool            `gorm:"default:1;comment:商品状态"` // 0下线，1上线
	GoodsType_Id    int
	GoodsSPU_Id     int
	GoodsImages     []*GoodsImage     `gorm:"foreignKey:GoodsSKU_Id;references:ID"`
	IndexGoodsTypes []*IndexGoodsType `gorm:"foreignKey:GoodsSKU_Id;references:ID"`
	IndexGoodsLoops []*IndexGoodsLoop `gorm:"foreignKey:GoodsSKU_Id;references:ID"`
	OrderGoods      []*OrderGoods     `gorm:"foreignKey:GoodsSKU_Id;references:ID"`
	gorm.Model
}

type GoodsImage struct { // 商品图片表
	ID          int
	Image       string `gorm:"comment:图片路径"`
	GoodsSKU_Id int
	gorm.Model
}

type IndexGoodsType struct { // 首页商品分类展示表
	ID           int
	Index        int `gorm:"default:0;comment:展示顺序"`
	DisplayType  int `gorm:"default:1;comment:展示类型"` // 0标题，1图片
	GoodsType_Id int
	GoodsSKU_Id  int
	gorm.Model
}

type IndexGoodsLoop struct { // 首页商品轮询展示表
	ID          int
	Image       string `gorm:"comment:图片"`
	Index       int    `gorm:"default:0;comment:展示顺序"`
	GoodsSKU_Id int
	gorm.Model
}

type IndexGoodsPromo struct { // 首页商品活动表
	ID    int
	Name  string `gorm:"size:20;comment:活动名称"`
	Url   string `gorm:"size:256;comment:活动链接"`
	Image string `gorm:"comment:活动图片"`
	Index int    `gorm:"default:0;comment:展示顺序"`
	gorm.Model
}
